package com.pacyki.adapters;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageButton;

import com.pacyki.datamodel.PostCardBackground;
import com.pacyki.gcards.R;

public class PostCardBackgroundsAdapter extends BaseAdapter {
	
	private Context mContext;
	private LayoutInflater mInflater;
	private ArrayList<PostCardBackground> mItems;
	
	public PostCardBackgroundsAdapter(Context context, ArrayList<PostCardBackground> items) {
		mContext = context;
		mItems = items;
		mInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	@Override
	public int getCount() {
		return mItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		PostCardBackgroundHolder holder;
		
		if (null == convertView){
			convertView = mInflater.inflate(R.layout.post_card_backgrounds_item, null, false);
			holder = new PostCardBackgroundHolder();
			holder.image = (ImageButton) convertView.findViewById(R.id.backgroundItemImageButton);
			convertView.setTag(holder);
		} else{
			holder = (PostCardBackgroundHolder) convertView.getTag();
		}

		//TODO : convert the current item to image in the curent view;
		PostCardBackground curItem = mItems.get(position);
		//ImageBitmap or Draweble = curItem.getPath();
		
		holder.image.setImageResource(R.drawable.hearts_green);
		return convertView;
	}
	
	public class PostCardBackgroundHolder {
		public ImageButton image;
	}
}